export default function debounce(handler, wait = 500) {
  if (typeof handler !== 'function') {
    throw new TypeError('handler is no function');
  }
  let args = arguments;
  let timer = null;

  return function () {
    clearTimeout(timer);
    timer = setTimeout(() => {
      handler.apply(this, args);
    }, wait);
  }
}
